package com.jackiechancinema.ssm.controller;

import com.jackiechancinema.ssm.bo.OrderBO;
import com.jackiechancinema.ssm.bo.ScheduleBO;
import com.jackiechancinema.ssm.entity.Commodit;
import com.jackiechancinema.ssm.entity.CommoditHead;
import com.jackiechancinema.ssm.entity.Schedule;
import com.jackiechancinema.ssm.service.Inte.CommoditService;
import com.jackiechancinema.ssm.service.Inte.ScheduleService;
import com.jackiechancinema.ssm.vo.PageVo;
import com.jackiechancinema.ssm.vo.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletResponse;

@RestController
@RequestMapping("/api/schedule/")
public class ScheduleController {
    @Autowired
    private ScheduleService scheduleService;

//    @GetMapping("page")
//    public PageVo<Schedule> page(int page, int limit){
//        return scheduleService.page(page, limit);
//    }

    @GetMapping("page")
    public PageVo<Schedule> page(ScheduleBO scheduleBO){
        return scheduleService.page(scheduleBO);
    }

    //删除档期
    @PostMapping("delete")
    public R delete(int scheduleId){
        return scheduleService.delete(scheduleId );
    }

    @PostMapping("add")
    public R add(Schedule schedule){
        return scheduleService.add(schedule);
    }

    @PostMapping("update")
    public R update(Schedule schedule){
        return scheduleService.update(schedule);
    }

    //文件上传
    @PostMapping("batchadd")
    public R batch(MultipartFile file){
        return scheduleService.batchadd(file);
    }

    @GetMapping("download")
    public void download(ScheduleBO o, HttpServletResponse response){
        scheduleService.exportExcel(o,response);
    }

}
